Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mixmix/custom-config #264

Merged
merged 46 commits into from
Dec 10, 2024
Merged

mixmix/custom-config #264

merged 46 commits into from
Dec 10, 2024

Conversation

mixmix
Copy link
Contributor

@mixmix mixmix commented Oct 22, 2024

This part of a PR chain:

mixmix/config-typesmixmix/load-entropymixmix/custom-config


The purpose of this PR is to be able to set a custom config file path for CLI

NOTES

  • the argParser cannot be async
    • => I think we're going to need to move config loading/parsing into the .action, probably loadEntropy
  • the TUI cannot take the same --config as the other leaf actions
    • using the same option in multiple levels leads to collisions
    • if we really want this in TUI then we need to make the tui launch a subcommand like entropy tui or entropy ui

@mixmix mixmix marked this pull request as draft October 22, 2024 22:53
@mixmix mixmix force-pushed the mixmix/custom-config branch from fe90ac6 to 8236b29 Compare October 23, 2024 02:20
@mixmix
Copy link
Contributor Author

mixmix commented Nov 4, 2024

resolve conflicts, get ready for review

@mixmix mixmix marked this pull request as ready for review November 6, 2024 03:55
@mixmix
Copy link
Contributor Author

mixmix commented Nov 6, 2024

NOTE: this is passing all tests but will need a really close review + smoke test before merge.
We're gonna do this after this current release

@frankiebee frankiebee requested a review from rh0delta November 6, 2024 18:36
@mixmix
Copy link
Contributor Author

mixmix commented Nov 7, 2024

@rh0delta I want you to try and break this. I think I got everything but dial up the pedantry with this one.

I turned of config.set taking a default config path, which then had typescript throwing everywhere it was not provided, but I bet there's still a place where something wrong has been written

Copy link
Contributor

@rh0delta rh0delta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks good from reading the code, will take some time to test out everything locally tho, so will hold off on the approval

Comment on lines -30 to -42
.argParser(aliasOrEndpoint => {
/* see if it's a raw endpoint */
if (aliasOrEndpoint.match(/^wss?:\/\//)) return aliasOrEndpoint

/* look up endpoint-alias */
const storedConfig = getConfigOrNull()
const endpoint = storedConfig?.endpoints?.[aliasOrEndpoint]
if (!endpoint) throw Error('unknown endpoint alias: ' + aliasOrEndpoint)

return endpoint
})
.default('wss://testnet.entropy.xyz/')
// NOTE: default cannot be "test-net" as argParser only runs if the -e/--endpoint flag
// or ENTROPY_ENDPOINT env set
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what was the need to delete all of this? I'm all for it, just wondering the reason why

Copy link
Contributor Author

@mixmix mixmix Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair question!

The addition of the of custom-config meant that we cannot do the argParser stuff here, because to do that you need access to the storedConfig, but you don't know that without the --config loaded and parsed, which we cannot reach from in this function ...

SO I moved it all out into the loadEntropy domain. The default should perhaps still be in there tho 🤔 (edit: it is)

src/common/utils-cli.ts Outdated Show resolved Hide resolved
src/common/utils-cli.ts Outdated Show resolved Hide resolved
src/common/utils.ts Show resolved Hide resolved
rh0delta and others added 6 commits November 13, 2024 16:01
* [NayNay] Testing Mix's Custom Config

- the general purpose of the custom config works, however there is alot of work to be done regarding error handling
- i have only started testing the custom config feature with a file that doesn't exist: ./custom-files/custom-config-<#>.json
- this originally caused issues on the tui and did not allow for anything to start until the tui eventually errored out
- similar errors were found with the cli as well
- ive fixed the tui for the most part
- but theres still lots to do to fix the cli in terms of proper error handling

* Update src/common/utils-cli.ts

* Update src/common/utils-cli.ts

* Update src/common/utils-cli.ts

* Update src/common/utils.ts

---------

Co-authored-by: mix irving <[email protected]>
This was referenced Nov 28, 2024
@mixmix mixmix marked this pull request as draft November 28, 2024 00:51
@mixmix mixmix changed the title Mixmix/custom config mixmix/custom-config Nov 28, 2024
@mixmix mixmix changed the base branch from dev to mixmix/load-entropy November 28, 2024 00:51
@mixmix mixmix marked this pull request as ready for review December 2, 2024 21:23
Base automatically changed from mixmix/load-entropy to dev December 10, 2024 00:49
@mixmix
Copy link
Contributor Author

mixmix commented Dec 10, 2024

e2e tests passing too :

yarn test:network:up
./tests/e2e.cli.sh
yarn test:network:down

@mixmix mixmix merged commit f923b90 into dev Dec 10, 2024
2 checks passed
@mixmix mixmix deleted the mixmix/custom-config branch December 10, 2024 04:43
@github-actions github-actions bot locked and limited conversation to collaborators Dec 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants